package com.atguigu.gmall.list.consumer;

import com.atguigu.gmall.list.service.SearchService;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * sku上架或下架的监听类
 */
@Component
@Log4j2
public class SkuUpOrDownListener {

    @Autowired
    private SearchService searchService;
    /**
     * 上架方法
     * @param msg
     */
    @RabbitListener(queues = "sku_queue_2")
    public void upper(String msg){
        log.info("商品上架，商品的id为:"+ msg);
        searchService.upperGoods(Long.parseLong(msg));
    }

    /**
     * 下架方法
     * @param msg
     */
    @RabbitListener(queues = "sku_queue_1")
    public void down(String msg){
        log.info("商品下架，商品的id为:"+ msg);
        searchService.lowerGoods(Long.parseLong(msg));
    }
}
